package com.example.culture

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.common.base.BaseActivity
import com.example.culture.databinding.ActivityCultureBinding
import com.example.culture.fragment.Announcements2Fragment
import com.example.culture.fragment.AnnouncementsFragment
import com.example.culture.fragment.CulturalFragment
import com.example.culture.fragment.CulturalManagermentFragment
import com.example.path.RouterPath

@Route(path = RouterPath.PATH_CULTURE)
class CultureActivity : BaseActivity<ActivityCultureBinding>() {

    @Autowired
    @JvmField
     var moduleType :String="7"

    override fun getLayoutId(): Int =R.layout.activity_culture
    override fun initViews() {
        ARouter.getInstance().inject(this)
        initFragment()
        mDataBinding.includedPageTitle.ivBack.setOnClickListener {
            finish()
        }
    }

    private fun initFragment() {
        when(moduleType){
            "7"->createFragment(CulturalFragment.newInstance(),"文化编辑")
            "8"->createFragment(AnnouncementsFragment.newInstance(),"公告管理")
            "9"->createFragment(CulturalManagermentFragment.newInstance(),"文化管理")
            "10"->createFragment(Announcements2Fragment.newInstance(),"公告管理")
        }
    }

    private fun createFragment(fragmentManger :Fragment, fragmentTag :String) {

        var fragments=supportFragmentManager
        val beginTransaction = fragments.beginTransaction()
        beginTransaction.replace(R.id.fragment,fragmentManger,fragmentTag)
        beginTransaction.commit()
        mDataBinding.includedPageTitle.tvTitle.text=fragmentTag
    }



}